package com.wn.login.service

import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.wn.common.constant.USER_SERVICE_USER
import com.wn.common.model.User
import com.wn.common.service.IUserService
import com.wn.login.utils.UserManager

/**
 * @Author: wn
 * @Date: 2025/7/9 17:26
 * @Description: 提供对 IUserService 接口的具体实现
 */
@Route(path = USER_SERVICE_USER)
class UserService : IUserService {
  /**
   * 是否登录
   * @return Boolean
   */
  override fun isLogin() = UserManager.isLogin()

  /**
   * 获取用户信息
   * @return User?
   */
  override fun getUserInfo(): User? = UserManager.getUserInfo()

  /**
   * 保存用户信息
   * @param user User?
   */
  override fun saveUserInfo(user: User) {
    UserManager.saveUserInfo(user)
  }

  /**
   * 清除用户信息
   */
  override fun clearUserInfo() {
    UserManager.clearUserInfo()
  }

  /**
   * 获取 User 信息 LiveData
   * @return LiveData<User?>
   */
  override fun getUserLiveData() = UserManager.getUserLiveData()

  /**
   * 保存用户手机号码
   * @param phone String?
   */
  override fun saveUserPhone(phone: String?) {
    UserManager.saveUserPhone(phone)
  }

  /**
   * 获取用户手机号码
   * @return String?
   */
  override fun getUserPhone() = UserManager.getUserPhone()

  /**
   * Do your init work in this method, it well be call when processor has been load.
   * @param context ctx
   */
  override fun init(context: Context?) {
  }
}